// Package trip_evaluation 模型
package trip_evaluation

import (
	// "gitee.com/sweetsunnyflower/carpooling-server-go/pkg/logger"
	"gitee.com/sweetsunnyflower/carpooling-server-go/app/models"
	"gitee.com/sweetsunnyflower/carpooling-server-go/pkg/database"
)

type TripEvaluation struct {
	models.BaseModel
	UserId     uint64 `gorm:"column:user_id" db:"user_id" json:"user_id" form:"user_id"`             //用户ID
	TripId     uint64 `gorm:"column:trip_id" db:"trip_id" json:"trip_id" form:"trip_id"`             //行程ID
	Evaluation uint8  `gorm:"column:evaluation" db:"evaluation" json:"evaluation" form:"evaluation"` //1:满意，2：不满意，3:还可以
	Anonymous  uint8  `gorm:"column:anonymous" db:"anonymous" json:"anonymous" form:"anonymous"`     //是否匿名，1：匿名，2：实名
	Comments   string `gorm:"type:varchar(255)" db:"comments" json:"comments" form:"comments"`       //评论内容
	models.CommonTimestampsField
}

func (tripEvaluation *TripEvaluation) Create() {
	database.DB.Create(&tripEvaluation)
}

func (tripEvaluation *TripEvaluation) Save() (rowsAffected int64) {
	result := database.DB.Save(&tripEvaluation)
	return result.RowsAffected
}

func (tripEvaluation *TripEvaluation) Delete() (rowsAffected int64) {
	result := database.DB.Delete(&tripEvaluation)
	return result.RowsAffected
}
